package com.example.demo.thread;

/**
 * @Author: liull
 * @Description: 主线程中创建三个子线程，这三个子线程需要保证一定的顺序，thrad1 --> thread2 -->thread3
 * @Date: Created in 17:04 2021/3/5
 * @Modified By:
 */
public class JoinTest2 {
    public static void main(String[] args) throws InterruptedException {
        final Thread thread1 = new Thread(() -> {
            System.out.println("产品经理规划新需求");
        });

        final Thread thread2 = new Thread(() -> {
            System.out.println("开发人员开发新需求功能");
        });

        final Thread thread3 = new Thread(() -> {
            System.out.println("测试人员测试新功能");
        });
        System.out.println("早上：");
        /********** 无法保证顺序执行 *************/
        // System.out.println("产品经理来上班了...");
        // thread1.start();
        // System.out.println("开发人员来上班了...");
        // thread2.start();
        // System.out.println("测试人员来上班了...");
        // thread3.start();
        /************* 无法保证顺序执行 ***************/
        System.out.println("##########");
        synchronized (JoinTest2.class){
            try{
                thread1.wait();
            }catch (Exception e){

            }
        }
    }
}
